package com.google.code.b0rx0r.advancedSamplerEngine.effect.modulation;

public class LinearEnvelopeInterpolationStrategy implements EnvelopeInterpolationStrategy {

	@Override
	public float getValue(float previousValue, int distanceFromPreviousValue, float nextValue, int distanceToNextValue) {
		float distance = distanceFromPreviousValue + distanceToNextValue;
		float weight = (float)distanceToNextValue / distance;
		
		return previousValue + (nextValue - previousValue) * weight;
	}

}
